load("//bzl:cpp_library.bzl", "cpp_library")

package(default_visibility = ["//visibility:public"])

cpp_library(
    name = "bucketed_time_series",
    hdrs = [
        "BucketedTimeSeries.h",
    ],
    textual_hdrs = [
        "BucketedTimeSeries-inl.h",
    ],
    deps = [
        "//folly:likely",
        "//folly/stats/detail:bucket",
        "@glog",
    ],
)

cpp_library(
    name = "histogram",
    hdrs = [
        "Histogram.h",
    ],
    textual_hdrs = [
        "Histogram-inl.h",
    ],
    deps = [
        "//folly:c_portability",
        "//folly:conv",
        "//folly:traits",
        "//folly/lang:exception",
        "//folly/stats/detail:bucket",
        "@glog",
    ],
)

cpp_library(
    name = "streaming_stats",
    hdrs = [
        "StreamingStats.h",
    ],
    deps = [
        "//folly/lang:exception",
    ],
)

cpp_library(
    name = "multi_level_time_series",
    hdrs = [
        "MultiLevelTimeSeries.h",
    ],
    textual_hdrs = [
        "MultiLevelTimeSeries-inl.h",
    ],
    deps = [
        ":bucketed_time_series",
        "//folly:constexpr_math",
        "//folly:string",
        "@glog",
    ],
)

cpp_library(
    name = "quantile_estimator",
    srcs = [
        "QuantileEstimator.cpp",
    ],
    hdrs = [
        "QuantileEstimator.h",
    ],
    textual_hdrs = [
        "QuantileEstimator-inl.h",
    ],
    deps = [
        ":tdigest",
        "//folly/stats/detail:buffered_stat",
    ],
)

cpp_library(
    name = "quantile_histogram",
    hdrs = [
        "QuantileHistogram.h",
    ],
    textual_hdrs = [
        "QuantileHistogram-inl.h",
    ],
    deps = [
        ":digest_builder",
        "//folly:conv",
        "//folly:glog",
        "//folly:likely",
        "//folly:range",
        "//folly:shared_mutex",
        "//folly/lang:align",
    ],
)

cpp_library(
    name = "tdigest",
    srcs = [
        "TDigest.cpp",
    ],
    hdrs = [
        "TDigest.h",
    ],
    deps = [
        "//folly:range",
        "//folly:utility",
        "//folly/stats/detail:double_radix_sort",
        "@glog",
    ],
)

cpp_library(
    name = "digest_builder",
    srcs = [],
    hdrs = [
        "DigestBuilder.h",
    ],
    textual_hdrs = [
        "DigestBuilder-inl.h",
    ],
    deps = [
        "//folly:memory",
        "//folly:spin_lock",
        "//folly/concurrency:cache_locality",
        "//folly/lang:bits",
    ],
)

cpp_library(
    name = "timeseries_histogram",
    hdrs = [
        "TimeseriesHistogram.h",
    ],
    textual_hdrs = [
        "TimeseriesHistogram-inl.h",
    ],
    deps = [
        ":histogram",
        ":multi_level_time_series",
    ],
)
